#include <iostream>
#include "user.pb.h"
#include "mprpcapplication.h"
#include "mprpcchannel.h"
#include "mprpccontroller.h"

int main(int argc, char **argv)
{
    MprpcApplication::init(argc, argv);

    Asukai::UserServiceRpc_Stub stub(new MprpcChannel());
    Asukai::LoginRequest req;
    req.set_username("Asukai");
    req.set_password("123456");

    Asukai::LoginResponse res;
    MprpcController controller;

    stub.Login(&controller, &req, &res, nullptr);

    if (controller.Failed())
    {
        std::cout << controller.ErrorText() << std::endl;
    }
    else
    {
        if (res.result().errcode() == 0)
        {
            std::cout << "rpc login success : " << res.success() << std::endl;
        }
        else
        {
            std::cout << "rpc login errpr : " << res.result().errmsg() << std::endl;
        }
    }

    return 0;
}